package project02.view;

import project02.domain.Job;
import project02.domain.User;
import project02.service.LoginService;
import project02.service.UserException;
import project02.service.UserListService;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.ArrayList;
import java.util.Scanner;

public class NameListView {
    private Scanner sc = new Scanner(System.in);
    static UserListService listSvc = new UserListService();

    //管理员管理主菜单
    public void DeveloperManageMainMenu() throws IOException, ClassNotFoundException {

        xiao:while (true) {
            System.out.println("🔣         ~用户系统管理主菜单~         🔣");
            System.out.println("🐕1.     <用户的查看>           *");
            System.out.println("🐖2.     <用户的添加>           *");
            System.out.println("🐱3.     <用户的修改>           *");
            System.out.println("🐂4.     <用户的删除>           *");
            System.out.println("🐇5.     <退出当前菜单>             *");
            System.out.print("⬇请选择：");
            char c = TSUtility.readMenuSelectionPro();
            switch (c) {
                case '1':
                    UserListService.getAllUser();
                    break;
                case '2':
                    System.out.println("请输入新用户的uid：");
                    String uid = sc.next();
                    System.out.println("请输入新用户的姓名：");
                    String name = sc.next();
                    UserListService.addUser(uid, name);
                    break;
                case '3':
                    System.out.println("输入需要修改用户的uid");
                    String uid1 = sc.next();
                    System.out.println("确定要调整该用户的信用等级？是【y】，否【n】");
                    String mod = sc.next();
                    if (mod == "y" || mod == "Y") {
                        System.out.println("请输入修改得信用等级：");
                        Integer level1 = sc.nextInt();
                        UserListService.modifyLevel(uid1, level1);
                    } else if (mod == "n" || mod == "N") {
                        DeveloperManageMainMenu();


                    }
                    break;
                case '4':
                    System.out.println("输入需要删除用户的uid");
                    String uid2 = sc.next();
                    System.out.println("确定要删除该用户？是【y】，否【n】");
                    String mod1 = sc.next();
                    if (mod1.equals("y")|| mod1.equals("Y")) {
                        UserListService.deleteUser(uid2);
                    } else if (mod1.equals("n")  || mod1.equals("N")) {
                        DeveloperManageMainMenu();


                    }
                    break;
                case '5':
                    break xiao;

            }
        }
    }}